In [ ]:
import pandas as pd
In [ ]:
series1 = pd.Series([1,2,3])
In [ ]:
series1
In [ ]:
names = pd.Series(['Pedro', 'JoãoR', 'Sam', 'Hugo'])
In [ ]:
names
In [ ]:
df1 = pd.DataFrame([ [1,2,3], [4,5,6] ])
In [ ]:
df1
In [ ]:
df2 = pd.DataFrame([[1,2,3],[4,5,6]], columns=['col1', 'col2', 'col3'])
In [ ]:
df2
In [ ]:
puns_per_day = pd.Series([72, 47, 4, 5])
In [ ]:
puns_per_day
In [ ]:
df2 = pd.DataFrame([names, puns_per_day])
In [ ]:
df2.head()
In [ ]:
df3 = pd.DataFrame()
In [ ]:
df3
In [ ]:
df3['names'] = names
In [ ]:
df3
In [ ]:
df3['puns_per_day'] = pd.Series([72, 47, 4, 5])
In [ ]:
df3
In [ ]:
df3['times_fired'] = [930, 48, 750, 355]
In [ ]:
df3
In [ ]:
df3 = df3.set_index('names')
In [ ]:
df3
In [ ]:
df3 = df3.reset_index()
In [ ]:
df3
In [ ]:
df3 = df3.set_index('times_fired')
In [ ]:
df3
In [ ]:
df3 = df3.sort_index()
In [ ]:
df3
In [ ]:
df3 = df3.sort_index(ascending=False)
In [ ]:
df3
In [ ]:
df3 = df3.reset_index()
In [ ]:
df3
In [ ]:
df_avengers = pd.read_csv('../data/avengers.csv')
In [ ]:
df_avengers.head()
In [ ]:
df_avengers.tail()
In [ ]:
df_avengers.shape
In [ ]:
df_avengers.dtypes
In [ ]:
df_avengers = df_avengers.set_index("Appearances")
In [ ]:
df_avengers.head()
In [ ]:
df_avengers = df_avengers.sort_index(ascending=False)
In [ ]:
df_avengers.head()
In [ ]:
# Notice how instead of assigning the variable, we use the argument 'inplace=True'
# This modifies the actual DataFrame, instead of returning a copy with the alteration.
df_avengers.reset_index(inplace=True)
In [ ]:
df_avengers.head()
In [ ]: